package com.zzj.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zzj.entity.Article;
import com.zzj.mapper.ArticleMapper;
import com.zzj.service.IArticleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author zzj
 * @since 2023-05-13
 */
@Service
public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> implements IArticleService {

    @Override
    public boolean setArticleStatus(int id, int status) {
        return this.update(new Article(),
                new LambdaUpdateWrapper<Article>().eq(Article::getId, id)
                        .eq(Article::getId, id)
                        .set(Article::getStatus, status));
    }

    @Override
    public Article id(int id) {
        return this.getOne(Wrappers.<Article>lambdaQuery()
                        .eq(Article::getId, id),
                false);
    }
}
